package edu.zut.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 代替的就是web.xml中的映射配置
 * name : servlet-name
 * urlPatterns : 映射路劲 ==  values
 * initParams: 配置当前servlet初始化参数
 */
@WebServlet(value = {"/demo5","/demo6","/demo7"},name = "demo5")
public class ServletDemo5 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //ServletConfig标识当前servlet对象的配置信息
        ServletConfig servletConfig = this.getServletConfig();
        String servletName = servletConfig.getServletName();
        System.out.println("servletName = " + servletName);
        //如何获取当前servlet的映射路劲
        String path = req.getServletPath();
        String uri = req.getRequestURI();
        StringBuffer url = req.getRequestURL();
    }
}